//
//  ViewController.m
//  fishhook
//
//  Created by czera on 2020/4/21.
//  Copyright © 2020 czera. All rights reserved.
//

#import "ViewController.h"
#import "fishhook.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
     //rebinding结构体
     struct rebinding nslog;
     nslog.name = "NSLog";
     nslog.replacement = myNSLog;
     nslog.replaced = (void *)&sys_nslog;
    
     //rebinding结构体数组
     struct rebinding rebs[1] = {nslog};
     /**
      * 存放rebinding结构体的数组
      * 数组的长度
      */
     rebind_symbols(rebs, 1);
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLog(@"点击了屏幕");
}

// ----- 更改 NSLog -----
// 函数指针
static void(*sys_nslog)(NSString *format,...);

// 定义一个新的函数
void myNSLog(NSString *format,...){
    format = [format stringByAppendingString:@"勾上了！！！！"];
    
    sys_nslog(format);
}

@end
